unit uniScreenItemAdd;

interface

uses
  uniScreenItem,
  uniEnemyAircraft,
  Classes;

type
  ItemThing = class;
  EnemyWave = class;

  { ScreenItemAdd }

  ScreenItemAdd = class(TObject)
  public
    root: ItemThing;
    deadPool: array[0..Integer(NumEnemyTypes) - 1] of EnemyAircraft;

    //game: Global;

    constructor Create;
    destructor Destroy; override;

    procedure putScreenItems;
    procedure killScreenItem(temp: ScreenItem);

    function loadScreenItems(temp: string): Boolean;
    procedure clear;

    function dynamicEnemyAdd(et: EnemyType; pos: array of Single; relTime: Integer): EnemyAircraft;

    procedure clearDeadPool;
    procedure addItem(relTime: Integer; newScreenItem: ScreenItem);
    procedure addWave(var ew: EnemyWave);

    procedure loadLevelXXX;
    procedure loadLevel1;
    procedure loadLevel2;
    procedure loadLevel3;

    procedure addStraightWave(o, duration: Integer; density: single = 1.0);
    procedure addOmniWave(o, duration: Integer; density: single = 1.0);
    procedure addStraightArrowWave(o, duration: Integer; density: single = 1.0);
    procedure addOmniArrowWave(o, duration: Integer; density: single = 1.0);
    procedure addGnatWave(o, duration: Integer; density: single = 1.0; mixed: Boolean = True);

    procedure addAmmunition(o, duration: Integer; a: Integer = 0; b: Integer = 100; c: Integer = 1000);
    procedure addPowerUps(o, duration: Integer; a: Integer = 300; b: Integer = 1200; c: Integer = 1000);
  end;

  { ItemThing }

  ItemThing = class(TObject)
  public
    releaseTime: Integer;
    item: ScreenItem;

    next: ItemThing;
    constructor Create; overload;
    constructor Create(relTime: Integer; newScreenItem: ScreenItem); overload;
    destructor Destroy; override;
  end;

  { EnemyWave }

  Formation =
    (
    None,
    Arrow,
    NumFormations
    );

  EnemyWave = class(TObject)
  public
    _type: EnemyType;
    _begin: Integer;
    _end: Integer;
    period: Integer;
    jitter: Integer;

    _formation: Formation;

    pos: array[0..2] of Single;
    xJitter: Single;

    constructor Create(t: EnemyType);
    destructor Destroy; override;

    procedure setInOut(b, e: Integer); {begin = b; end = e; if(e <= b) end = b+1;}
    procedure setPos(x, y: Single); {pos[0] = x; pos[1] = y;}
    procedure setXRand(j: Single); {xJitter = j;}
    procedure setFrequency(p: Integer; j: Integer = 0); {period = p; jitter = j;}
    procedure setFormation(f: Formation); {formation = f; }

  end;

implementation

uses
  uniDefine,
  uniPowerUps,
  uniGlobal;

{ ScreenItemAdd }

procedure ScreenItemAdd.addAmmunition(o, duration, a, b, c: Integer);
var
  i: Integer;
  ammoPause00, ammoPause01, ammoPause02: Integer;
  skill: Single;
  p: array[0..2] of Single;
  v: array[0..2] of Single;
begin
  ammoPause00 := a + Round(FRAND*200);
  ammoPause01 := b + Round(FRAND*200);
  ammoPause02 := c + Round(FRAND*500);
  skill := 2.0 - uniGlobal.gameSkill;
  p[0] := 0.0;
  p[1] := 9.0;
  p[2] := 25.0;

  v[0] := 0;
  v[1] := 0;
  v[2] := 0;

  for i := o to o + duration - 1 do
  begin
    Dec(ammoPause00);
    Dec(ammoPause01);
    Dec(ammoPause02);
    p[0] := 8.0 * SRAND;
    if ammoPause00 < 1 then
    begin
      ammoPause00 := Round(skill * 2000 + (SRAND * 500));
      addItem(i, PowerUp.Create(HeroAmmo00, p, v));
    end
    else
    begin
      if ammoPause01 < 1 then
      begin
        ammoPause01 := Round(skill * 2500 + (SRAND * 1000));
        addItem(i, PowerUp.Create(HeroAmmo01, p, v));
      end
      else
      begin
        if ammoPause02 < 1 then
        begin
          ammoPause02 := Round(skill * skill * 4000 + (SRAND * 1000));
          addItem(i, PowerUp.Create(HeroAmmo02, p, v));
        end;
      end;
    end;
  end;
end;

procedure ScreenItemAdd.addGnatWave(o, duration: Integer; density: single; mixed: Boolean);
var
  freq: Single;
  c: Single;
  straightArrow, omniArrow, gnatWave: EnemyWave;
begin
  freq := 1.0 / density;
  c := -FRAND * 3.0;

  if mixed then
  begin
    straightArrow := EnemyWave.Create(EnemyStraight);
    straightArrow.setInOut(o + 50, o + duration);
    straightArrow.setXRand(0.0);
    straightArrow.setPos(c, 10.0);
    straightArrow.setFrequency(Round(90 * freq), 20);
    straightArrow.setXRand(8.0);
    if c > 0.0 then
    begin
      addWave(straightArrow);
    end
    else
    begin
      omniArrow := EnemyWave.Create(EnemyOmni);
      omniArrow.setInOut(o + 50, o + 130);
      omniArrow.setPos(c, 10.0);
      omniArrow.setFrequency(Round(20 * freq), 0);
      omniArrow.setXRand(1.1);
      addWave(omniArrow);
      omniArrow.setInOut(o + 320, o + 400);
      addWave(omniArrow);
      straightArrow.setInOut(o + 200, o + 250);
      addWave(straightArrow);
    end;
    gnatWave := EnemyWave.Create(EnemyGnat);
    gnatWave.setInOut(o, o + Round((25 * uniGlobal.gameSkill) * (1.0 + FRAND * 0.2)));
    gnatWave.setPos(SRAND * 5.0, 10.0);
    gnatWave.setFrequency(Round(3 * freq), 0);
    gnatWave.setXRand(3.0);
    addWave(gnatWave);
  end
  else
  begin
    gnatWave := EnemyWave.Create(EnemyGnat);
    gnatWave.setPos(-3.0 + SRAND * 5.0, 10.0);
    gnatWave.setFrequency(Round(1 * freq), 0);
    gnatWave.setXRand(3.0);
    gnatWave.setInOut(o, o + 35);
    addWave(gnatWave);
    gnatWave.setPos(SRAND * 5.0, 10.0);
    gnatWave.setInOut(o + 300, o + 310);
    addWave(gnatWave);
    gnatWave.setFrequency(Round(30 * freq), 0);
    gnatWave.setInOut(o + 300, o + 400);
    addWave(gnatWave);
  end;
end;

procedure ScreenItemAdd.addItem(relTime: Integer; newScreenItem: ScreenItem);
var
  curItem, newItem: ItemThing;
begin
  curItem := root;
  newItem := ItemThing.Create(relTime, newScreenItem);

  while Boolean(curItem) do
  begin
    if curItem.next = nil then
    begin
      curItem.next := newItem;
      Break;
    end;
    if relTime < curItem.next.releaseTime then
    begin
      newItem.next := curItem.next;
      curItem.next := newItem;
      Break;
    end;
    curItem := curItem.next;
  end;
end;

procedure ScreenItemAdd.addOmniArrowWave(o, duration: Integer; density: single);
var
  freq, c: Single;
  omniArrow: EnemyWave;
begin
  freq := 1.0 / density;
  c := SRAND * 2.0;
  omniArrow := EnemyWave.Create(EnemyOmni);
  omniArrow.setFormation(Arrow);
  omniArrow.setPos(c, 10.0);
  omniArrow.setFrequency(Round(25 * freq), 0);
  omniArrow.setXRand(1.0);
  omniArrow.setInOut(o + 50, o + 150);
  addWave(omniArrow);
  omniArrow.setInOut(o + 250, o + 320);
  addWave(omniArrow);
  omniArrow.setInOut(o + 300, o + 330);
  addWave(omniArrow);
  omniArrow.setInOut(o + 350, o + 470);
  addWave(omniArrow);
  omniArrow.setFrequency(5, 0);
  omniArrow.setXRand(1.8);
  omniArrow.setInOut(o + 550, o + 555);
  addWave(omniArrow);
end;

procedure ScreenItemAdd.addOmniWave(o, duration: Integer; density: single);
var
  freq: Single;
  omniWave, straightWave: EnemyWave;
begin
  freq := 1.0 / density;
  omniWave := EnemyWave.Create(EnemyOmni);
  omniWave.setXRand(1.0);
  omniWave.setFrequency(Round(39 * freq), 7);
  omniWave.setPos((SRAND * 8.0), 9.0);
  omniWave.setInOut(o, Round(o + (duration / 2) + 50));
  addWave(omniWave);
  omniWave.setPos((SRAND * 8.0), 9.0);
  omniWave.setInOut(Round(o + (duration / 2) - 50), o + duration);
  addWave(omniWave);
  straightWave := EnemyWave.Create(EnemyStraight);
  straightWave.setXRand(8.0);
  straightWave.setFrequency(200, 50);
  straightWave.setInOut(o + 100, o + duration);
  addWave(straightWave);
end;

procedure ScreenItemAdd.addPowerUps(o, duration, a, b, c: Integer);
var
  i: Integer;
  pwrPause00, pwrPause01, pwrPause02: Integer;
  p: array[0..2] of Single;
  v: array[0..2] of Single;
begin
  pwrPause00 := a + Round(FRAND*500);
  pwrPause01 := b + Round(FRAND*500);
  pwrPause02 := c + Round(FRAND*1000);

  p[0] := 0.0;
  p[1] := 9.0;
  p[2] := 25.0;

  v[0] := 0.0;
  v[1] := 0.0;
  v[2] := 0.0;

  for i := o to o + duration - 1 do
  begin
    Dec(pwrPause00);
    Dec(pwrPause01);
    Dec(pwrPause02);
    p[0] := 8.0 * SRAND;
    if pwrPause00 < 1 then
    begin
      pwrPause00 := 2500 + Round(SRAND * 700);
      addItem(i, PowerUp.Create(Shields, p, v));
    end
    else
    begin
      if pwrPause01 < 1 then
      begin
        pwrPause01 := 4000 + Round(SRAND * 900);
        addItem(i, PowerUp.Create(Repair, p, v));
      end
      else
      begin
        if pwrPause02 < 1 then
        begin
          pwrPause02 := 5000 + Round(SRAND * 3000);
          addItem(i, PowerUp.Create(SuperShields, p, v));
        end;
      end;
    end;
  end;
end;

procedure ScreenItemAdd.addStraightArrowWave(o, duration: Integer; density: single);
var
  freq, c: Single;
  straightArrow, omniWave: EnemyWave;
begin
  freq := 1.0 / density;
  c := SRAND;
  straightArrow := EnemyWave.Create(EnemyStraight);
  straightArrow.setInOut(o, o + 130);
  straightArrow.setXRand(0.0);
  straightArrow.setPos(c, 10.0);
  straightArrow.setFrequency(Round(50 * freq), 0);
  straightArrow.setXRand(1.6);
  straightArrow.setFormation(Arrow);
  addWave(straightArrow);
  omniWave := EnemyWave.Create(EnemyOmni);
  omniWave.setFrequency(Round(15 * freq), 5);
  omniWave.setPos(c, 9.0);
  omniWave.setXRand(2.0);
  omniWave.setInOut(o + 220, o + 260);
  addWave(omniWave);
  omniWave.setXRand(3.0);
  omniWave.setFrequency(Round(22 * freq), 5);
  omniWave.setInOut(o + 440, o + 600);
  addWave(omniWave);
end;

procedure ScreenItemAdd.addStraightWave(o, duration: Integer; density: single);
var
  freq: Single;
  straightWave: EnemyWave;
begin
  freq := 1.0 / density;
  straightWave := EnemyWave.Create(EnemyStraight);
  straightWave.setXRand(8.0);
  straightWave.setFrequency(Round(60 * freq), 5);
  straightWave.setInOut(o, o + duration);
  addWave(straightWave);
end;

procedure ScreenItemAdd.addWave(var ew: EnemyWave);
var
  i, interval, iteration: Integer;
  p: array[0..2] of Single;
  jitter, period: Integer;
begin
  interval := 1;
  iteration := 0;
  //p[3] = { ew.pos[0], ew.pos[1], ew.pos[2] };
  p[0] := ew.pos[0];
  p[1] := ew.pos[1];
  p[2] := ew.pos[2];
  jitter := Round(ew.jitter * (2.0 - uniGlobal.gameSkill));
  period := Round(ew.period * (2.0 - uniGlobal.gameSkill));
  if jitter >= period then
    jitter := period - 1;
  for i := ew._begin to ew._end - 1 do
  begin
    Dec(interval);
    if interval < 1 then
    begin
      case ew._formation of
        None:
          begin
            p[0] := ew.pos[0] + ew.xJitter * SRAND;
            addItem(i, makeNewEnemy(ew._type, p));
            interval := period + Round(SRAND * jitter);
          end;
        Arrow:
          begin
            p[0] := ew.pos[0] + ew.xJitter * iteration;
            addItem(i, makeNewEnemy(ew._type, p, 0.0));
            if iteration > 0 then
            begin
              p[0] := ew.pos[0] - ew.xJitter * iteration;
              addItem(i, makeNewEnemy(ew._type, p, 0.0));
            end;
            interval := period + Round(SRAND * jitter);
            Inc(iteration);
          end;
      else
        p[0] := 0.0;
        addItem(i, makeNewEnemy(ew._type, p, 0.0));
        interval := 25;
      end;
    end;
  end;
end;

procedure ScreenItemAdd.clear;
var
  cur, del: ItemThing;
begin

  cur := root.next;
  while Boolean(cur) do
  begin
    cur.item.Destroy;
    del := cur;
    cur := cur.next;
    del.Destroy;
  end;
  root.next := nil;
  clearDeadPool;
end;

procedure ScreenItemAdd.clearDeadPool;
var
  cur, del: EnemyAircraft;
  i: Integer;
begin

  for i := 0 to Integer(NumEnemyTypes) - 1 do
  begin
    cur := deadPool[i].next;
    while Boolean(cur) do
    begin
      del := cur;
      cur := cur.next;
      del.Destroy;
    end;
    deadPool[i].next := nil;
  end;
end;

constructor ScreenItemAdd.Create;
var
  i: Integer;
  p: array[0..2] of Single;
begin
  //game = Global::getInstance();

  root := ItemThing.Create;
  //loat p[3] := { 0.0, 0.0, 0.0 };
  p[0] := 0;
  p[1] := 0;
  p[2] := 0;
  for i := 0 to Integer(NumEnemyTypes) - 1 do
  begin
    deadPool[i] := makeNewEnemy(EnemyType(i), p);
    deadPool[i].next := nil;
  end;
end;

destructor ScreenItemAdd.Destroy;
begin
  clear;
  root.Destroy;
  //inherited;
end;

function ScreenItemAdd.dynamicEnemyAdd(et: EnemyType; pos: array of Single; relTime: Integer): EnemyAircraft;
var
  addEnemy: EnemyAircraft;
begin

  if Boolean(deadPool[Integer(et)].next) then
  begin
    addEnemy := deadPool[Integer(et)].next;
    deadPool[Integer(et)].next := addEnemy.next;
    addEnemy.init(pos);
  end
  else
  begin
    addEnemy := makeNewEnemy(et, pos);
  end;
  addItem(relTime, addEnemy);
  Result := addEnemy;
end;

procedure ScreenItemAdd.killScreenItem(temp: ScreenItem);
var
  enemy: EnemyAircraft;
begin

  case temp.itemType of
    ItemEnemy: // add enemy to dead pool
      begin
        enemy := EnemyAircraft(temp);
        enemy.back := nil;
        enemy.next := deadPool[Integer(enemy._type)].next;
        deadPool[Integer(enemy._type)].next := enemy;
      end;
  else
    temp.Destroy;
  end;
end;

procedure ScreenItemAdd.loadLevel1;
begin
  loadLevelXXX;
end;

procedure ScreenItemAdd.loadLevel2;
var
  i, numIterations: Integer;
  waves: Integer;
  r: Single;
  waveDuration: Integer;

  gnatWave, bossWave: EnemyWave;
begin
  numIterations := 14000;
  clearDeadPool;
  //-- Enemies
  waves := 0;
  waveDuration := 500;
  i := 500;
  addStraightWave(100, i, 0.4);

  while i < numIterations do
  begin
    r := FRAND;
    Inc(waves);
    if (waves = 5) or (waves = 6) or
      (waves = 11) or (waves = 12) or
      (waves = 15) or (waves = 16) then
    begin
      addGnatWave(i, waveDuration, 1.0, false);
    end
    else
    begin
      if waves < 5 then
      begin
        if (r < 0.20) then addStraightArrowWave(i, waveDuration)
        else if (r < 0.30) then addOmniArrowWave(i, waveDuration)
        else if (r < 0.60) then addOmniWave(i, waveDuration)
        else addStraightWave(i, waveDuration);
      end
      else
      begin
        if (r < 0.25) then addGnatWave(i, waveDuration)
        else if (r < 0.35) then addStraightArrowWave(i, waveDuration)
        else if (r < 0.50) then addOmniArrowWave(i, waveDuration)
        else if (r < 0.80) then addOmniWave(i, waveDuration)
        else addStraightWave(i, waveDuration);
      end;
    end;
    i := i + waveDuration;
    waveDuration := Round(700.0 + 100.0 * SRAND);
    i := i + 50 + Round(50 * FRAND);
  end;

  gnatWave := EnemyWave.Create(EnemyGnat);
  gnatWave.setInOut(2200, 5000);
  gnatWave.setPos(FRAND * 4.0, 10.0);
  gnatWave.setFrequency(150, 140);
  gnatWave.setXRand(5.0);
  addWave(gnatWave);

  //-- Boss
  bossWave := EnemyWave.Create(EnemyBoss01);
  bossWave.setPos(0.0, 15.0);
  bossWave.setXRand(4.0);
  bossWave.setFrequency(5000, 0);
  bossWave.setInOut(numIterations + 700, numIterations + 710);
  addWave(bossWave);

  //-- Ammunition and PowerUps
  addAmmunition(0, numIterations + 9000);
  addPowerUps(0, numIterations + 9000);
end;

procedure ScreenItemAdd.loadLevel3;
var
  i, numIterations: Integer;
  waves: Integer;
  r: Single;
  waveDuration: Integer;

  tankWave, gnatWave, bossWave, tankWave2: EnemyWave;
begin

  numIterations := 14000;

  clearDeadPool;
  //-- Enemies
  waves := 0;
  waveDuration := 500;
  i := 500;
  addStraightWave(100, i, 0.5);

  while i < numIterations do
  begin
    r := FRAND;
    Inc(waves);
    if (waves = 5) or (waves = 12) then
    begin
      addGnatWave(i, waveDuration, 0.9, false);
    end
    else
    begin
      if (waves = 6) or (waves = 11) or
        (waves = 15) or (waves = 16) then
      begin
        tankWave := EnemyWave.Create(EnemyTank);
        tankWave.setPos(0.0, 11.0);
        tankWave.setXRand(10.0);
        tankWave.setFrequency(700, 100);
        tankWave.setInOut(i + 50, waveDuration - 50);
        addWave(tankWave);
        addStraightWave(i, 300);
      end
      else
      begin
        if waves < 5 then
        begin
          if (r < 0.20) then addStraightArrowWave(i, waveDuration)
          else if (r < 0.30) then addOmniArrowWave(i, waveDuration)
          else if (r < 0.60) then addOmniWave(i, waveDuration)
          else addStraightWave(i, waveDuration);
        end
        else
        begin
          if (r < 0.25) then addGnatWave(i, waveDuration)
          else if (r < 0.35) then addStraightArrowWave(i, waveDuration)
          else if (r < 0.50) then addOmniArrowWave(i, waveDuration)
          else if (r < 0.80) then addOmniWave(i, waveDuration)
          else addStraightWave(i, waveDuration);
        end;
      end;
      i := i + waveDuration;
      waveDuration := Round(700.0 + 100.0 * SRAND);
      i := i + 50 + Round(50 * FRAND);
    end;
  end;


  gnatWave := EnemyWave.Create(EnemyGnat);
  gnatWave.setInOut(3000, 5000);
  gnatWave.setPos(FRAND * 4.0, 10.0);
  gnatWave.setFrequency(150, 140);
  gnatWave.setXRand(5.0);
  addWave(gnatWave);

  gnatWave.setInOut(8000, 11000);
  addWave(gnatWave);

  //-- give some extra power ups...
  addAmmunition(0, 2000, 500, 700, 0);
  addAmmunition(10000, 2000, 500, 700, 0);
  addPowerUps(3000, 2000, 2500, 2500, 0);
  addPowerUps(9500, 2000, 2500, 2500, 0);
  addPowerUps(numIterations, 2000, 2500, 2500, 1);

  //-- Boss
  bossWave := EnemyWave.Create(EnemyBoss01);
  bossWave.setPos(0.0, 15.0);
  bossWave.setXRand(4.0);
  bossWave.setFrequency(5000, 0);
  bossWave.setInOut(numIterations + 700, numIterations + 710);
  addWave(bossWave);

  tankWave2 := EnemyWave.Create(EnemyTank);
  tankWave2.setPos(0.0, 11.0);
  tankWave2.setXRand(10.0);
  tankWave2.setFrequency(2000, 200);
  tankWave2.setInOut(numIterations + 400, numIterations + 3000);
  addWave(tankWave2);

  //-- Ammunition and PowerUps
  addAmmunition(0, numIterations + 9000);
  addPowerUps(0, numIterations + 9000);
end;

procedure ScreenItemAdd.loadLevelXXX;
var
  i, numIterations: Integer;
  waves: Integer;
  r, d: Single;
  waveDuration: Integer;

  rayWave, bossWave: EnemyWave;
begin
  numIterations := 12000;
  clearDeadPool;
  //-- Enemies
  waveDuration := 500;
  i := 600;
  addStraightWave(1, i, 0.4);

  while i < numIterations - 1000 do
  begin
    if i < 1500 then
      d := (i + 250.0) / 2000.0
    else
      d := 1.0;
    r := FRAND;
    if (r < 0.15) then addStraightArrowWave(i, waveDuration, d)
    else if (r < 0.25) then addOmniArrowWave(i, waveDuration, d)
    else if (r > 0.60) then addStraightWave(i, waveDuration, d)
    else addOmniWave(i, waveDuration, d);
    i := i + waveDuration;
    waveDuration := Round(600.0 * uniGlobal.gameSkill) + Round(100 * SRAND);
    i := i + 50 + Round(50 * FRAND);
  end;

  //-- ray gun enemy starts halfway through...
  rayWave := EnemyWave.Create(EnemyRayGun);
  rayWave.setXRand(8.0);
  rayWave.setFrequency(60, 5);
  rayWave.setFrequency(2000, 1000);
  rayWave.setInOut(Round(numIterations / 2), i - 1000);
  addWave(rayWave);

  //-- Boss
  bossWave := EnemyWave.Create(EnemyBoss00);
  bossWave.setInOut(i + 75, i + 1000);
  bossWave.setPos(0.0, 15.0);
  bossWave.setXRand(4.0);
  bossWave.setFrequency(5000, 0);
  addWave(bossWave);

  //-- Ammunition and PowerUps
  addAmmunition(0, numIterations + 9000);
  addPowerUps(0, numIterations + 9000);
end;

function ScreenItemAdd.loadScreenItems(temp: string): Boolean;
begin
  case ((uniGlobal.gameLevel - 1) mod 3) of
    0: loadLevel1;
    1: loadLevel2;
    2: loadLevel3;
  else
    loadLevel1;
  end;

  Result := True;
end;

procedure ScreenItemAdd.putScreenItems;
var
  curItem: ItemThing;
begin
  curItem := root.next;
  while Boolean(curItem) do
  begin
    if curItem.releaseTime <= uniGlobal.gameFrame then
    begin
      case curItem.item.ItemType of
         ItemEnemy: _enemyFleet.addEnemy(EnemyAircraft(curItem.item));
         ItemPowerUp: _powerUps.addPowerUp(PowerUp(curItem.item));
         ItemHero: Writeln('ScreenItemAdd::putScreenItems() Hero??? HUH???');
      end;
      curItem := curItem.next;
      root.next := curItem;
    end
    else
    begin
      curItem := nil;
    end;
  end;
end;

{ ItemThing }

constructor ItemThing.Create;
begin
  releaseTime := -1;
  item := nil;
  next := nil;
end;

constructor ItemThing.Create(relTime: Integer; newScreenItem: ScreenItem);
begin
  releaseTime := relTime;
  item := newScreenItem;
  next := nil;
end;

destructor ItemThing.Destroy;
begin

  inherited;
end;

{ EnemyWave }

constructor EnemyWave.Create(t: EnemyType);
begin
  _type := t;
  _begin := 1;
  _end := 500;
  period := 60;
  jitter := 10;
  _formation := None;

  pos[0] := 0.0;
  pos[1] := 10.0;
  pos[2] := 25.0;
  xJitter := 8.0;
end;

destructor EnemyWave.Destroy;
begin

  inherited;
end;

procedure EnemyWave.setFormation(f: Formation);
begin
  _formation := f;
end;

procedure EnemyWave.setFrequency(p, j: Integer);
begin
  period := p; jitter := j;
end;

procedure EnemyWave.setInOut(b, e: Integer);
begin
  _begin := b; _end := e; if e <= b then _end := b + 1;
end;

procedure EnemyWave.setPos(x, y: Single);
begin
  pos[0] := x; pos[1] := y;
end;

procedure EnemyWave.setXRand(j: Single);
begin
  xJitter := j;
end;

end.

